//
//  QZShopInfoHeaderView.m
//  WeiWeiHaircut
//
//  Created by apple on 15/12/9.
//  Copyright © 2015年 超群. All rights reserved.
//

#import "QZShopInfoHeaderView.h"

#import "QZShopInfoModel.h"
@interface QZShopInfoHeaderView()<UIScrollViewDelegate>
@property (weak, nonatomic) IBOutlet UIScrollView *scrollView;
@property (weak, nonatomic) IBOutlet UILabel *berofLabel;
@property (weak, nonatomic) IBOutlet UILabel *priceLabel;
@property (weak, nonatomic) IBOutlet UILabel *payNumber;
@property (weak, nonatomic) IBOutlet UIPageControl *pageView;

@end
@implementation QZShopInfoHeaderView

- (void)awakeFromNib {

    _priceLabel.textColor = purColor2;
    
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    
}

-(void)setFrame:(CGRect)frame{
    [super setFrame:frame];
    
    _scrollView.bounces = YES;
    _scrollView.pagingEnabled = YES;
    _scrollView.delegate = self;
    
    NSArray *array = @[@"1123.jpg",@"1123.jpg",@"1123.jpg"];
    
    for (int i = 0; i< array.count; i++) {
        
        UIImageView *view = [[UIImageView alloc] initWithFrame:CGRectMake(WIDTH*i, 0, WIDTH, _scrollView.frame.size.width)];
        view.image = [UIImage imageNamed:array[i]];
        
        [_scrollView addSubview:view];
    }
    
    _scrollView.contentSize = CGSizeMake(WIDTH*array.count, 0);
    _pageView.numberOfPages = array.count;
    
}

-(void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView{
   
    NSInteger index = scrollView.contentOffset.x/WIDTH;
    
    _pageView.currentPage = index;
    
}

-(void)setShopInfoModel:(QZShopInfoModel *)shopInfoModel{
    _shopInfoModel = shopInfoModel;
    
    _berofLabel.text = shopInfoModel.prodTitle;
    
    _priceLabel.text = [NSString stringWithFormat:@"￥%@",shopInfoModel.price2];
    
    _payNumber.text = [NSString stringWithFormat:@"%ld人付款",shopInfoModel.saleNum];
    
    
}

@end
